//import 'package:alpha_player_plugin/alpha_player_view.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:ball_lion/server/http/request_header.dart';
import 'package:ball_lion/utils/utils.dart';

// enum GiftEffectType{
//   socket(path: "assets/file/socket.mp4");
//
//   final String path;
//
//   const GiftEffectType({required this.path});
// }

class GiftEffectController with ChangeNotifier {
  GiftEffectController._interval();
  static final GiftEffectController _instance =
      GiftEffectController._interval();
  factory GiftEffectController() => _instance;

  //AlphaPlayerController player = AlphaPlayerController();
  List<String> playList = [];
  bool offStage = true;

  play(String path) async {
    if (RequestHeader.brand == "HONOR") return;
    offStage = false;
    playList.add(path);
    // if (playList.length == 1)
    //   player.start(path,
    //       isLooping: false, align: AlphaPlayerScaleType.ScaleAspectFill);
    notifyListeners();
  }

  void complete(String? path) {
    offStage = true;
    playList.removeAt(0);
    // if (playList.isNotEmpty) {
    //   offStage = false;
    //   player.start(playList.first,
    //       isLooping: false, align: AlphaPlayerScaleType.ScaleAspectFill);
    // }
    notifyListeners();
  }

  clear() => playList = [];
}

class GiftEffect extends StatefulWidget {
  const GiftEffect({super.key});

  @override
  State<GiftEffect> createState() => _GiftEffectState();
}

class _GiftEffectState extends State<GiftEffect> {
  @override
  void didChangeDependencies() {
    GiftEffectController().addListener(() {
      setState(() {});
    });
    super.didChangeDependencies();
  }

  @override
  Widget build(BuildContext context) {
    return Offstage(
      offstage: GiftEffectController().offStage,
      child: Container(),
      // child: AlphaPlayerView(
      //   width: context.width, height: context.height,
      //   controller: GiftEffectController().player,
      //   onCompleted: GiftEffectController().complete,
      // ),
    );
  }
}
